package lesson12;

import java.util.Comparator;

/**
 * 自定义排序器
 */
public class MyComparator implements Comparator<Student> {
    @Override
    public int compare(Student s1, Student s2) {
//        Student s1 = (Student) o1;
//        Student s2 = (Student) o2;
//        if(s1.getAge() > s2.getAge()){
//            return -1;
//        }else if(s1.getAge() < s2.getAge()){
//            return 1;
//        }else{
//            return 0;
//        }
        return s1.getAge() - s2.getAge();
    }
}
